package com.sangmo.fts.teacher.service;

import com.sangmo.boot.framework.plugin.dataview.crud.service.BaseViewService;
import com.sangmo.boot.framework.plugin.dataview.data.IDataViewRepo;
import com.sangmo.fts.teacher.interfaces.GrowthRatioSettingCreation;
import com.sangmo.fts.teacher.model.GrowthRatioSetting;
import com.sangmo.fts.teacher.repo.GrowthRatioSettingRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class GrowthSettingEntityService extends BaseViewService<GrowthRatioSetting> {

    @Autowired
    private GrowthRatioSettingRepo growthRatioSettingRepo;

    @Override
    protected IDataViewRepo<GrowthRatioSetting> getRepo() {
        return growthRatioSettingRepo;
    }

    public void create(Long scoreSettingId, List<GrowthRatioSettingCreation> list) {
        for (GrowthRatioSettingCreation bo : list) {
            bo.setScoreSettingId(scoreSettingId);
            this.create(bo);
        }
    }

    public void deleteByScoreSettingId(Long scoreSettingId) {
        growthRatioSettingRepo.deleteByScoreSettingId(scoreSettingId);
    }

    public List<GrowthRatioSetting> findByScoreSettingId(Long scoreSettingId) {
        return growthRatioSettingRepo.findByScoreSettingId(scoreSettingId);
    }

}
